using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Yunwei.Domain.Models.Mapping
{
    public class VendorMap : EntityTypeConfiguration<Vendor>
    {
        public VendorMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired();

            this.Property(t => t.Address)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Phone)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Avatar)
                .IsRequired();

            this.Property(t => t.User_Id)
                .IsRequired();

            this.Property(t => t.Contact)
                .IsRequired();

            this.Property(t => t.X).HasPrecision(18, 6);
            this.Property(t => t.Y).HasPrecision(18, 6);

            // Table & Column Mappings
            this.ToTable("Vendor");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.X).HasColumnName("X");
            this.Property(t => t.Y).HasColumnName("Y");
            this.Property(t => t.Avatar).HasColumnName("Avatar");
            this.Property(t => t.User_Id).HasColumnName("User_Id");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Contact).HasColumnName("Contact");
        }
    }
}
